﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="DJJCXX_Manage.aspx.cs" Inherits="Xiaov.SmartWeb.Application.PluginSrc.StatisticalSystem.OGWell.DJJCXX_Manage" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
          
        <script type="text/javascript" src="/Resources/xiaovcn/scripts/common.js" ></script>
    <script type="text/javascript" src="/Resources/xiaovcn/scripts/usercheck.js"></script>
    <script type="text/javascript" src="/Resources/easyui-1.32/locale/easyui-lang-zh_CN.js"></script>
    <script type="text/javascript" src="/Resources/easyui-1.32/datagrid-view/datagrid-bufferview.js"></script>
        <script type="text/javascript">

            function callback(res) {
                if (res.value) {
                    rebindgrid();
                    $.messager.alert('提示', '操作成功！');
                }
                else {
                    $.messager.alert(res.error);
                }
            }

            var a,b,c,c_1,d,e,f,g,h,i,j

            function getvalues()
            {
                a = $('#t1').val();
                b = $('#t2').combobox('getValue');
                c = $('#t3').combobox('getValue');
                c_1 = $('#t3_1').combobox('getValue');
                d = $('#t4').combobox('getValue');
                e = $('#t5').val();
                f = $('#t6').datebox('getValue');
                g = $('#t7').combobox('getValue');
                h = $('#t8').combobox('getValue');
                i = $('#t9').val();
                j = $('#t10').val();
            }

            function save() {
                
                getvalues();

                Xiaov.SmartWeb.Application.PluginSrc.StatisticalSystem.OGWell.DJJCXX_Manage.Save(a, b, c, c_1, d, e, f, g, h, i, j, callback);
                clearForm();
                rebindgrid();
            }

            function del(row) {
                Xiaov.SmartWeb.Application.PluginSrc.StatisticalSystem.OGWell.DJJCXX_Manage.Delete(row.JH, callback);
                rebindgrid();
            }

            function rebindgrid() {
                //$('#tt').datagrid('reload');
                $('#tt').datagrid('reload');
                $('#add').window('close');
            }
           

            function bindgrid() {
                $('#tt').datagrid({
                    title: '单井基础信息列表',
                    url: 'Json/DJJCXX.aspx?dwbm=<%=PUser.USERDEPT%>',
                    //data: [{ jh: a, dwbm: b, dqbm: c, cxbm: d, cyjh: e, tcrq: f, sczt: g, jb: h, bz: i, rowid: j }],
                    iconCls: 'icon-applicationgo',
                    nowrap: true,
                    rownumbers: true,
                    animate: false,
                    collapsible: false,
                    singleSelect: true,
                    remoteSort: false,
                    //view: bufferview,
                   pageSize:30,
                    pagination:true,
                    columns: [[
                             { field: 'JH', title: '井号', width: 100, sortable: true, formatter: function (val, rec) { return unescape(val) } },
                             { field: 'DWMC', title: '单位名称', sortable: true, width: 100, formatter: function (val, rec) { return unescape(val) } },
                             { field: 'DQMC', title: '地区名称', width: 100, formatter: function (val, rec) { return unescape(val) } },
                             { field: 'QKMC', title: '区块名称', width: 100, formatter: function (val, rec) { return unescape(val) } },
                             { field: 'CXMC', title: '层系', width: 100, formatter: function (val, rec) { return unescape(val) } },
                             { field: 'CYJH', title: '曾用井号', width: 100, formatter: function (val, rec) { return unescape(val) } },
                             { field: 'TCRQ', title: '投产日期', width: 100, formatter: function (val, rec) { return unescape(val) } },
                             { field: 'SCZT', title: '生产状态', width: 100, formatter: function (val, rec) { return unescape(val) } },
                             { field: 'JB', title: '井别', width: 100, formatter: function (val, rec) { return unescape(val) } },
                             { field: 'BZ', title: '备注', width: 100, formatter: function (val, rec) { return unescape(val) } },
                    ]],
                    toolbar: [{
                        text: '增加',
                        iconCls: 'icon-add',
                        handler: function () {
                            //增加用户
                            clearForm();
                            $('#add').window('open');
                            $("#t1").removeAttr("disabled");
                            $('#search').hide();
                            $('#save').show();
                        }
                    }, '-', {
                        text: '修改',
                        iconCls: 'icon-edit',
                        handler: function () {
                            editrow();
                        }
                    }, '-', {
                        text: '删除',
                        iconCls: 'icon-cancel',
                        handler: function () {
                            var row = $('#tt').datagrid('getSelected');
                            if (row) {
                                $.messager.confirm('提示', '确定要删除【' + unescape(row.JH) + '】吗?', function (r) {
                                    if (r) {
                                        del(row);
                                    }
                                    else {
                                        alert('请选中一行');
                                    }
                                });
                            }
                        }
                    }, '-', {
                        text: ' 搜索',
                        iconCls: 'icon-search',
                        handler: function () {
                            $("#t1").removeAttr("disabled");
                            clearForm();
                            $('#add').window('open');
                            $('#add').panel('setTitle', ' 搜索数据');
                            $('#search').show();
                            $('#save').hide();
                        }
                    }],
                    onLoadSuccess: function () {
                        //$('#mask').fadeOut();
                    },
                    onDblClickRow: function () {
                        editrow();
                    }
                });
            }

            function se() {
                $('#add').panel('setTitle', ' 基础信息');
                getvalues();
                $('#tt').datagrid('load', { jh: a, dwbm: b, dqbm: c, qkbm:c_1,cxbm: d, cyjh: e, tcrq: f, sczt: g, jb: h, bz: i, rowid: j });
                $('#add').window('close');
            }

            function editrow() {
                //编辑
                $('#search').hide();
                $('#save').show();
                var row = $('#tt').datagrid('getSelected');
                if (row) {
                    $('#add').window('open');
                    $("#t1").attr("disabled", "disabled");
                    $('#t1').attr('value', row.JH);
                    $('#t2').combobox('setValue', row.DWBM);
                    $('#t3').combobox('setValue', row.DQBM);
                    $('#t3_1').combobox('setValue', row.QKBM);
                    $('#t4').combobox('setValue', row.CXBM);
                    $('#t5').attr('value', row.CYJH);
                    $('#t6').datebox('setValue', row.TCRQ);
                    $('#t7').combobox('setValue', unescape(row.SCZT));
                    $('#t8').combobox('setValue', unescape(row.JB));
                    $('#t9').attr('value', row.BZ);
                    $('#t10').attr('value', row.Rowid);
                }
                else {
                    alert('请选中一行');
                }
            }

            $(function () {
                bindgrid();                
            });


           </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">    
     <table id="tt">
    </table> 
     <script>
         $('#tt').css('height', userScreenHeight+25);
    </script>
    <div id="add" class="easyui-window" closed="true" modal="true" title=" 基础信息" iconCls="icon-applicationgo" style="width:500px; padding:5px;">
    <div id="contents" class="ssec-form" style="padding-top:5px">      
        <table>
         <tr>
                <td><div class="ssec-label">井号：</div></td>
                <td><div class="ssec-text normal"><asp:TextBox ID="t1" ClientIDMode="Static" runat="server" CssClass="ssec-text-field "></asp:TextBox></div></td>             
           </tr> 
        <tr>
                <td><div class="ssec-label">单位：</div></td>
                <td><div class="ssec-text normal">
                    <select id="t2" class="easyui-combobox" style="width:200px"  data-options="valueField:'id',textField:'text',url:'json/danwei.aspx',panelHeight:200"></select>
                    </div></td>             
           </tr> 
        <tr>
                <td><div class="ssec-label">地区：</div></td>
                <td><div class="ssec-text normal">
                    <select id="t3" class="easyui-combobox" style="width:200px" data-options="valueField:'id',textField:'text',url:'json/diqu.aspx',panelHeight:120"></select>
                    </div></td>             
        </tr> 
       <tr>
                <td><div class="ssec-label">区块：</div></td>
                <td><div class="ssec-text normal">
                    <select id="t3_1" class="easyui-combobox" style="width:200px" data-options="valueField:'id',textField:'text',url:'json/Qukuai.aspx',panelHeight:120"></select>
                    </div></td>             
        </tr> 
        <tr>
                <td><div class="ssec-label">层系：</div></td>
                <td><div class="ssec-text normal"> 
                    <select id="t4" class="easyui-combobox" style="width:200px" data-options="valueField:'id',textField:'text',url:'json/cengxi.aspx',panelHeight:120">
                    </select>
                    </div></td>             
        </tr> 
        <tr>
                <td><div class="ssec-label">曾用井号：</div></td>
                <td><asp:TextBox ID="t5" ClientIDMode="Static" runat="server" CssClass="ssec-text-field "></asp:TextBox></td>             
        </tr> 
        <tr>
                <td><div class="ssec-label">投产日期：</div></td>
                <td><asp:TextBox ID="t6" ClientIDMode="Static" runat="server" CssClass="easyui-datebox "></asp:TextBox></td>             
        </tr>
        <tr>
            <td><div class="ssec-label">生产状态：</div></td>
            <td>
                <select id="t7" class="easyui-combobox" style="width:200px" panelHeight="60px">
                    <option value="在产">在产</option>
                    <option value="停产">停产</option>
                </select>
                </td>
        </tr> 
        <tr>
            <td><div class="ssec-label">井别：</div></td>
            <td><select id="t8" class="easyui-combobox" style="width:200px" panelHeight="100px">
                    <option value="未知" selected>未知</option>
                    <option value="油井">油井</option>
                    <option value="气井">气井</option>
                    <option value="注水井">注水井</option>
                </select></td>
        </tr> 
        <tr>
                <td><div class="ssec-label">备注：</div></td>
                <td><div class="ssec-text normal"><asp:TextBox ID="t9" ClientIDMode="Static" runat="server" ></asp:TextBox></div></td>             
        </tr>         
            </table>
        <asp:HiddenField ID="t10" ClientIDMode="Static" runat="server" />
        <div style="padding:5px 5px" ><a  id="save" class="easyui-linkbutton"  onclick="save();" iconCls="icon-save">确定</a>
            <a  class="easyui-linkbutton" id="search" onclick="se();" iconCls="icon-search" style="display:none;">搜索</a></div> 
     </div>
    </div>
</asp:Content>
